package cn.edu.nuc.ssm.controller;

import cn.edu.nuc.ssm.entity.User;
import cn.edu.nuc.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2017/5/5.
 */
@Controller
@RequestMapping("/user")
public class BackUserController {

    @Autowired
    private UserService userService;


    @RequestMapping(value = "/tolist",method = RequestMethod.GET)
    public String tolist() {

        return "back/user/list";

    }

    @ResponseBody
    @RequestMapping(value = "/listuser",method = RequestMethod.GET)
    public List<User> list(){

        return userService.findAll();
    }

    @ResponseBody
    @RequestMapping(value = "/freeze",method = RequestMethod.GET)
    public String freeze(int id){

        userService.freeze(id);

        return "success";
    }

    @ResponseBody
    @RequestMapping(value = "/defreeze",method = RequestMethod.GET)
    public String defreeze(int id){

        userService.defreeze(id);

        return "success";
    }

}
